import React from 'react';
import { connect } from 'dva';
import PropTypes from 'prop-types';
import styles from './index.css';
import auth from 'utils/auth';
import { routerRedux } from 'dva/router';

function IndexPage({ dispatch }) {
  if (!auth.loggedIn()) {
    dispatch(routerRedux.push('/login'));
  }

  return (
    <div className={styles.normal}>
      <h5 className={styles.title}>绘本运营管理后台</h5>
      <div className={styles.welcome} />
    </div>
  );
}

if (process.env.UMI_ENV !== 'prod') {
  IndexPage.propTypes = {
    dispatch: PropTypes.func.isRequired,
  };
}

IndexPage.defaultProps = {
  dispatch: () => {},
};

export default connect()(IndexPage);
